package com.fzy.designpattern.iterator;

import java.util.ArrayList;

public class ConcreteIterator implements Iterator {

    private ArrayList<Object> list = new ArrayList<Object>();
    private int cursor = 0;

    public ConcreteIterator(ArrayList<Object> list) {
        this.list = list;
    }

    @Override
    public Object next() {
        if (this.hasNext()) {
            return this.list.get(cursor++);
        }
        return null;
    }

    @Override
    public boolean hasNext() {
        if (this.cursor == this.list.size())
            return false;
        return true;
    }

}
